/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "quartier")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Quartier.findAll", query = "SELECT q FROM Quartier q"),
    @NamedQuery(name = "Quartier.findByIdQuartier", query = "SELECT q FROM Quartier q WHERE q.idQuartier = :idQuartier")})
public class Quartier implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_QUARTIER")
    private Integer idQuartier;
    @Lob
    @Size(max = 65535)
    @Column(name = "LIBELLE")
    private String libelle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idQuartier")
    private Collection<Personne> personneCollection;
    @JoinColumn(name = "ID_VILLE", referencedColumnName = "ID_VILLE")
    @ManyToOne(optional = false)
    private Ville idVille;

    public Quartier() {
    }

    public Quartier(Integer idQuartier) {
        this.idQuartier = idQuartier;
    }

    public Integer getIdQuartier() {
        return idQuartier;
    }

    public void setIdQuartier(Integer idQuartier) {
        this.idQuartier = idQuartier;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    @XmlTransient
    public Collection<Personne> getPersonneCollection() {
        return personneCollection;
    }

    public void setPersonneCollection(Collection<Personne> personneCollection) {
        this.personneCollection = personneCollection;
    }

    public Ville getIdVille() {
        return idVille;
    }

    public void setIdVille(Ville idVille) {
        this.idVille = idVille;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idQuartier != null ? idQuartier.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Quartier)) {
            return false;
        }
        Quartier other = (Quartier) object;
        if ((this.idQuartier == null && other.idQuartier != null) || (this.idQuartier != null && !this.idQuartier.equals(other.idQuartier))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.Quartier[ idQuartier=" + idQuartier + " ]";
    }
    
}
